package org.finir.fakturisanje.persistence.beans;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;

import org.finir.fakturisanje.persistence.Faktura;
import org.finir.fakturisanje.persistence.Komitent;
import org.finir.fakturisanje.persistence.Preduzece;
import org.finir.fakturisanje.persistence.Skladiste;
import org.finir.fakturisanje.persistence.Usluga;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Role;
import org.jboss.seam.annotations.Scope;

@Entity
@Name("preduzece")
@Scope(ScopeType.PAGE)
@Role(name = "preduzeceLoggedIn", scope = ScopeType.SESSION)
public class PreduzeceBean implements Preduzece, Serializable {

	private static final long serialVersionUID = 1L;

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#getId()
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#setId(java.lang.Long)
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#getNaziv()
	 */
	public String getNaziv() {
		return naziv;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#setNaziv(java.lang.String)
	 */
	public void setNaziv(String naziv) {
		this.naziv = naziv;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#getMesto()
	 */
	public String getMesto() {
		return mesto;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#setMesto(java.lang.String)
	 */
	public void setMesto(String mesto) {
		this.mesto = mesto;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#getAdresa()
	 */
	public String getAdresa() {
		return adresa;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#setAdresa(java.lang.String)
	 */
	public void setAdresa(String adresa) {
		this.adresa = adresa;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#getZiroRacun1()
	 */
	public String getZiroRacun1() {
		return ziroRacun1;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#setZiroRacun1(java.lang.String)
	 */
	public void setZiroRacun1(String ziroRacun1) {
		this.ziroRacun1 = ziroRacun1;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#getTelefon()
	 */
	public String getTelefon() {
		return telefon;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#setTelefon(java.lang.String)
	 */
	public void setTelefon(String telefon) {
		this.telefon = telefon;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#getJIB()
	 */
	public String getJIB() {
		return JIB;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#setJIB(java.lang.String)
	 */
	public void setJIB(String jib) {
		JIB = jib;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#getJMB()
	 */
	public String getJMB() {
		return JMB;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#setJMB(java.lang.String)
	 */
	public void setJMB(String jmb) {
		JMB = jmb;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#getOpstinaRegistracije()
	 */
	public String getOpstinaRegistracije() {
		return opstinaRegistracije;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#setOpstinaRegistracije(java.lang.String)
	 */
	public void setOpstinaRegistracije(String opstinaRegistracije) {
		this.opstinaRegistracije = opstinaRegistracije;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are
		// not set
		if (!(object instanceof PreduzeceBean)) {
			return false;
		}
		PreduzeceBean other = (PreduzeceBean) object;
		if ((this.id == null && other.id != null)
				|| (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		// TODO Auto-generated method stub
		return naziv + "          " + adresa;
	}

	private Long id;

	private String naziv;
	private String mesto;
	private String adresa;

	private String ziroRacun1;
	private String telefon;
	private String JIB;
	private String JMB;
	private String opstinaRegistracije;
	private List<Faktura> fakture;
	private List<Komitent> komitenti;
	private List<Skladiste> skladista;
	private List<Usluga> usluge;
	private String username;
	private String password;

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@OneToMany(cascade = CascadeType.ALL, targetEntity = UslugaBean.class, mappedBy = "preduzece")
	public List<Usluga> getUsluge() {
		return usluge;
	}

	public void setUsluge(List<Usluga> usluge) {
		this.usluge = usluge;
	}

	@OneToMany(cascade = CascadeType.ALL, targetEntity = SkladisteBean.class, mappedBy = "preduzece")
	public List<Skladiste> getSkladista() {
		return skladista;
	}

	public void setSkladista(List<Skladiste> skladista) {
		this.skladista = skladista;
	}

	@OneToMany(cascade = CascadeType.ALL, targetEntity = KomitentBean.class, mappedBy = "preduzece")
	public List<Komitent> getKomitenti() {
		return komitenti;
	}

	public void setKomitenti(List<Komitent> komitenti) {
		this.komitenti = komitenti;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#getFakture()
	 */
	@OneToMany(targetEntity = FakturaBean.class, cascade = CascadeType.ALL, mappedBy = "preduzece")
	public List<Faktura> getFakture() {
		return fakture;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see domain.beans.preduze#setFakture(java.util.List)
	 */
	public void setFakture(List<Faktura> fakture) {
		this.fakture = fakture;
	}

}
